module PlaneTest(tests) where

import Plane
import Test.HUnit
import TestHelper

bottomTests =
    TestList["no points" @! bottom [],
             "one point" ~: (0,0) @=? bottom [(0,0)],
             "two first lower" ~: (30,0) @=? bottom [(30,0), (0,1)],
             "two second lower" ~: (30,0) @=? bottom [(0,1), (30,0)],
             "two same height first left" ~: (0,0) @=? bottom[(0,0), (1,0)],
             "two same height first right" ~: (0,0) @=? bottom[(1,0), (0,0)],
             "many" ~: (10,(-10)) @=?
                        bottom [((-1),3), (0,0), (10, (-10)), (40, 12),
                                (100, (-10))]
            ]

turnDirectionTests =
    TestList["left" ~: LeftTurn @=? turnDirection (0,0) (2,2) (1,3),
             "right" ~: RightTurn @=? turnDirection (1,1) (2,3) (4,0),
             "straight forward" ~: Straight @=? turnDirection (1,1) (2,2) (3,3),
             "straight back" ~: Straight @=? turnDirection (1,1) (3,3) (2,2)
            ]

grahamScanSortTests =
    TestList["abc" ~: [(0,0), (3,1), (2,2)] @=?
                   grahamScanSort [(0,0), (3,1), (2,2)],
             "acb" ~: [(0,0), (3,1), (2,2)] @=?
                   grahamScanSort [(0,0), (2,2), (3,1)],
             "bac" ~: [(0,0), (3,1), (2,2)] @=?
                   grahamScanSort [(3,1), (0,0), (2,2)],
             "bca" ~: [(0,0), (3,1), (2,2)] @=?
                   grahamScanSort [(3,1), (2,2), (0,0)],
             "cab" ~: [(0,0), (3,1), (2,2)] @=?
                   grahamScanSort [(2,2), (0,0), (3,1)],
             "cba" ~: [(0,0), (3,1), (2,2)] @=?
                   grahamScanSort [(2,2), (3,1), (0,0)],
             "daceb" ~: [(1,-1), (5,0), (2,2), (0,0), (-5,0)] @=?
                     grahamScanSort [(0,0), (1,-1), (2,2), (-5,0), (5,0)]]

convexHullTests =
    TestList["caXb" ~: [(0,0), (3,1), (2,2)] @=?
                    convexHull [(2,2), (0,0), (2,1), (3,1)],
             "abcX" ~: [(0,0), (3,1), (2,2)] @=?
                    convexHull [(0,0), (3,1), (2,2), (2,1)],
             "aeXdbXc" ~: [(2,0),(4,1),(3,3),(2,3),(0,1)] @=?
                       convexHull [(2,0),(0,1),(3,2),(2,3),(4,1),(1,1),(3,3)],
             "multiple right turns" ~: [(0,0),(10,1),(17,4)] @=?
                                    convexHull[(0,0),(10,1),(12,2),
                                               (13,3),(17,4)]]

tests = TestList[bottomTests, turnDirectionTests, grahamScanSortTests,
                 convexHullTests]
